package com.you.bio.socketio;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SocketClient {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 8080);
        OutputStream outputStream = socket.getOutputStream();
        InputStream inputStream = socket.getInputStream();
        byte[] buff = new byte[100];
        for (int i = 0; i < 1000; i++) {
            String sendStr = new String(i + "");
            outputStream.write(sendStr.getBytes());
            System.out.println(System.currentTimeMillis() + "---发送了：" + sendStr);
            int replaylen = inputStream.read(buff);
            System.out.println("---接收到回复：" + new String(buff, 0, replaylen));
        }
        outputStream.close();
        socket.close();
    }
}
